<?php
namespace Home\Controller;
use Lib\Alidayu\SendSMS;
class FalseController extends CommonController {

public function _initialize()
{
		$this->Is_login();        //检测用户登录信息,如果错误直接返回错误,终止程序
		$this->assign('heardadminData',session('heardadminData'));
}

//创建订单
public function false_add()
{
		$labeldata = M("label")->select();//读取配置
		$medialist = M("media")->field('id,media_name')->select();
		$leveldata = M("systemsetup")->where(array("type"=>1))->order('value desc')->select();
		// p($leveldata);exit();
		$this->assign('labeldata',$labeldata);
		$this->assign('medialist',$medialist);
		$this->assign('leveldata',$leveldata);
		$this->display();
}

public function add_false()
{
	// p($_POST);exit();
	$mid = I('post.media');
	$label = I('post.label');
	$sex = I('post.sex');
	$title = I('post.title');
	$article = I('post.article');
	$user_type = I('post.user_type');
	$level = I('post.level');//主播等级id
	$wordnumber = I('post.wordnumber');//字数
	$moneynumber = I('post.moneynumber');//原价
	$discount = I('post.discount');//折扣
	$usemoney = I('post.usemoney');//实价
	$plan_time = I('post.plan_time');//预计时间（分钟）
	$is_collect = I('post.is_collect');//不为0是收藏主播
	$isvip = I('post.isvip');//1是vip
	$audio = QN_AUDIO_URL.I('post.audio');//1是vip
	if (I('post.special') == 0) {
		$special = 0;
	}else{
		$special = I('post.special');
	}

	$mname = M("media")->field('media_name')->where("id=$mid")->find();
	$systemdata = M("systemsetup")->where("id=3")->where(array("type"=>0))->find();
	$order = D("order");
	if (!$order->create()){//自动验证
		$this->error('参数错误',"",1);
	}else{
		$now_time = time();
		$data = $order->create(); // 保存生成的数据对象
		$data['mid'] = $mid;
		$data['mname'] = $mname['media_name'];
		$data['title'] = $title;
		$data['sex'] = $sex;
		$data['texttype'] = $label;
		$data['wordnumber'] = $wordnumber;
		$data['number'] = get_orderid();
		$data['price'] = $moneynumber;
		$data['discount'] = $discount;
		$data['money'] = $usemoney;
		$data['ordertime'] = $now_time;
		$data['starttime'] = $now_time;
		$data['plantime'] = $now_time+$plan_time*60;
		$data['overtime'] = $now_time+$plan_time*60+60;
		$data['uuid'] = 100001;
		$data['describe_audio'] = $audio;
		$data['status'] = 5;
		$data['level'] = $level;
		$data['is_collect'] = $is_collect;
		$data['is_vip'] = 0;
		$data['special'] = $special;
		$data['peoplenumber'] = 1;
		$data['getnumber'] = 1;

		// p($data);exit();
		$result = $order->add($data);
		$article_data['article'] = $article;
		$article_data['oid'] = $result;
    M("article")->add($article_data);//插入文章数据
		$this->success('模拟下单成功',"/Home/Order/order_list",1);

	}

}


}